package com.wenhao.test.jsontest03;

import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.LinkedList;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class JsonUtils {

	public void parseUserJson(String jsonData){
		Type listType = new TypeToken<LinkedList<User>>(){}.getType();
		Gson gson = new Gson();
		LinkedList<User> users = gson.fromJson(jsonData, listType);
		
		Iterator<User> iter = users.iterator();
		
		while(iter.hasNext()){
			User user = (User)iter.next();
			System.out.println("name---->" + user.getName());
			System.out.println("age----->" + user.getAge());
		}

	}
}
